﻿CREATE TABLE [dbo].[Vizite] (
    [IDVizita]  INT      IDENTITY (1, 1) NOT NULL,
    [Data]      DATETIME CONSTRAINT [DF_Vizite_Data] DEFAULT (getdate()) NOT NULL,
    [IDAgent]   INT      CONSTRAINT [DF_Vizite_IDAgent] DEFAULT ((0)) NOT NULL,
    [Ordine]    SMALLINT CONSTRAINT [DF_Vizite_Ordine] DEFAULT ((0)) NOT NULL,
    [Vizitat]   BIT      CONSTRAINT [DF_Vizite_Vizitat] DEFAULT ((0)) NOT NULL,
    [IDClient]  INT      CONSTRAINT [DF_Vizite_IDClient] DEFAULT ((0)) NOT NULL,
    [IDMagazin] INT      NULL,
    [IDTraseu]  INT      CONSTRAINT [DF_Vizite_IDTraseu] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_Vizite] PRIMARY KEY CLUSTERED ([IDVizita] ASC),
    CONSTRAINT [FK_Vizite_Agenti] FOREIGN KEY ([IDAgent]) REFERENCES [dbo].[Agenti] ([IDAgent]),
    CONSTRAINT [FK_Vizite_PunctLucru] FOREIGN KEY ([IDMagazin]) REFERENCES [dbo].[PunctLucru] ([IDPunctLucru]),
    CONSTRAINT [FK_Vizite_Trasee] FOREIGN KEY ([IDTraseu]) REFERENCES [dbo].[Trasee] ([IDTraseu])
);

